package com.enroll.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.enroll.dao.FacultyDao;
import com.enroll.model.Faculty;
import com.enroll.util.CustomHibernateDaoSupport;

@Repository("facultyDao")
public class FacultyDaoImpl extends CustomHibernateDaoSupport implements FacultyDao {

	@Override
	public void save(Faculty faculty) {
		getHibernateTemplate().save(faculty);
	}


	@Override
	public void update(Faculty faculty) {
		getHibernateTemplate().update(faculty);
	}

	@Override
	public void delete(Faculty faculty) {
		getHibernateTemplate().delete(faculty);
		
	}

	@Override
	@SuppressWarnings("rawtypes")
	public Faculty findById(int id) {
		List list = getHibernateTemplate().find("from Faculty where id=?",id);
		return (Faculty) list.get(0);
	}


	@SuppressWarnings("unchecked")
	@Override
	public List<Faculty> findAll() {
		List<Faculty> faculties = getHibernateTemplate().find("from Faculty");
		return faculties;
		
	}
}
